package com.ruoyi.service.impl;

import java.util.List;

import com.ruoyi.domain.Course;
import com.ruoyi.domain.Student;
import com.ruoyi.domain.Teacher;
import com.ruoyi.domain.TeacherEvaluation;
import com.ruoyi.mapper.TeacherMapper;
import com.ruoyi.service.ITeacherEvaluationService;
import com.ruoyi.service.ITeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 教师Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-04-22
 */
@Service
public class TeacherServiceImpl implements ITeacherService
{
    @Autowired
    private TeacherMapper teacherMapper;
    @Autowired
    private ITeacherEvaluationService teacherEvaluationService;

    /**
     * 查询教师
     * 
     * @param teacherId 教师主键
     * @return 教师
     */
    @Override
    public Teacher selectTeacherByTeacherId(Long teacherId)
    {
        return teacherMapper.selectTeacherByTeacherId(teacherId);
    }

    /**
     * 查询教师列表
     * 
     * @param teacher 教师
     * @return 教师
     */

    @Override
    public List<Teacher> selectTeacherList(Teacher teacher)
    {
        return teacherMapper.selectTeacherList(teacher);
    }

    /**
     * 新增教师
     * 
     * @param teacher 教师
     * @return 结果
     */

    @Override
    public int insertTeacher(Teacher teacher)
    {
        return teacherMapper.insertTeacher(teacher);
    }

    /**
     * 修改教师
     * 
     * @param teacher 教师
     * @return 结果
     */
    @Override
    public int updateTeacher(Teacher teacher)
    {
        return teacherMapper.updateTeacher(teacher);
    }

    /**
     * 批量删除教师
     * 
     * @param teacherIds 需要删除的教师主键
     * @return 结果
     */
    @Override
    public int deleteTeacherByTeacherIds(Long[] teacherIds)
    {
        return teacherMapper.deleteTeacherByTeacherIds(teacherIds);
    }

    /**
     * 删除教师信息
     * 
     * @param teacherId 教师主键
     * @return 结果
     */
    @Override
    public int deleteTeacherByTeacherId(Long teacherId)
    {
        return teacherMapper.deleteTeacherByTeacherId(teacherId);
    }

    @Override
    public List<Course> getCourseByTeacherId(Long teachId) {
        return teacherMapper.getCourseByTeacherId(teachId);

    }

    @Override
    public List<Student> getStudent(Long teachId, Long courseId, String courseName, String studentName) {
        if (courseName != null){
            courseName = "%"+courseName + "%";
        }
        if (studentName != null){
            studentName = "%"+studentName + "%";
        }
        return teacherMapper.getStudent(teachId,courseId,courseName , studentName);
    }

    @Override
    public List<Teacher> getTeacher(Long studentId) {
        return teacherMapper.getTeacher(studentId);
    }

    @Override
    public List<Teacher> getAllTeacherRate(String teacherName) {
        if (teacherName != null){
            teacherName = "%"+teacherName + "%";
        }
        return teacherMapper.getTeacherRate(teacherName);
    }

    @Override
    public TeacherEvaluation getTeacherRate(Long teachId, Long studentId) {
        return teacherEvaluationService.getTeacherRate(teachId,studentId);
    }

    @Override
    public List<Teacher> getAllTeach() {
        return teacherMapper.getAllTeach();
    }
}
